package com.example.gamestore.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.example.gamestore.Bean.Game;
import com.example.gamestore.mapper.GameMapper;
import com.example.gamestore.mapper.UserMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class ThreadService {
    @Async("taskExecutor")
    public void updateViewCounts(GameMapper mapper, Game game){
        Integer viewcount = game.getViewcount();
        Game gameupdate=new Game();
        gameupdate.setViewcount(viewcount+1);
        LambdaUpdateWrapper<Game> wrapper=new LambdaUpdateWrapper<>();
        wrapper.eq(Game::getId,game.getId());
        mapper.update(gameupdate,wrapper);
    }
}
